package wikitools.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import wikitools.model.TextBase;
import wikitools.model.TextBaseFactory;
import wikitools.util.XMLUtil;

public class DeleteArticle extends HttpServlet{

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
        deleteArticle(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
        deleteArticle(req, resp);
    }

    private void deleteArticle(HttpServletRequest request, HttpServletResponse response) {
        String id = request.getParameter("id");
        TextBase db = TextBaseFactory.getTextBase();
        db.removeArticleById(id);     
        response.setStatus(201); //resource created
        
        
    }
    
}
